|
|
|
| Table A.6. continued | | Script Word | Handling Comments | | DBMAKE | This is the CreateDatabase word. If a line starts with this keyword, call a special routine (SQLdbMake) that executes a Visual Basic CreateDatabase operation. | | DBQUIET | Use this keyword to suppress the display of SQL-VB5 when you call it from other programs (using the object model). If this value is set to True, no screens appear; only the script is processed. | | DBCLOSE | This is the CloseDatabase word. If a line begins with this keyword, call a special routine (SQLdbClose) that executes a Visual Basic Close operation on a database object. |
|
|
|
|
|
|
If the word found at the start of the line is not one of those listed in Table A.6, the program assumes that it is a valid SQL word and adds the entire line to the variable cSQLLine. After doing this, the routine checks to see whether the current line ends with a semicolon (;). If so, the program attempts to execute the SQL statement using the SQLDoCommand routine. After executing this routine, the cSQLLine variable is cleared in preparation for the next SQL statement. |
|
|
|
|
|
|
|
|
This process is repeated until the program reaches the end of the script file. At that time, the routine exits SQLFileProcess and returns to the SQLMain routine. |
|
|
|
|
|
|
|
|
Now would be a good time to save the SQLVBMOD code module and save the project. You can't run the program at this point because you added references to several routines that do not yet exist. You add those final routines in the next section. |
|
|
|
|
|
|
|
|
Creating the Support Routines |
|
|
|
|
|
|
|
|
Now that you have entered all the main routines, you need to add several support routines. Almost all these support routines are called directly from SQLFileProcess. You concentrate on those first and add others as needed. |
|
|
|
|
|
|
|
|
The first routine called from SQLFileProcess is GetToken. This routine takes a line of script and returns the first word in the list. You use this word (often referred to as a token) as a way to determine how SQLFileProcess handles each line of script. Because GetToken returns a value, it is a function. To create a Visual Basic function, select Insert | Procedure. Enter the function name as GetToken(cString As String) As String and select the Function radio button. Now enter the code in Listing A.15 in the code window. |
|
|
|
|
|